﻿<MudDrawer @bind-Open="@_isOpen"
           Class="pa-6"
           Anchor="Anchor.End"
           Elevation="1"
           Width="350px"
           Variant="@DrawerVariant.Temporary">
    <MudDrawerContainer>

        <MudSwitch Value="@(_isAutostart)"
                   T="bool"
                   ValueChanged="AutostartChange"
                   Label="@(Lang["Autostart"])"
                   Color="Color.Primary" />

        <MudSwitch @bind-Value="@(AppSettings.IsHideWindowWhenLaunch)"
                   @bind-Value:after="SaveSettings"
                   Label="@(Lang["HideWindowWhenLaunch"])"
                   Color="Color.Primary" />
        <MudSwitch @bind-Value="@(AppSettings.IsHideWindowWhenClose)"
                   @bind-Value:after="SaveSettings"
                   Label="@(Lang["HideWindowWhenClose"])"
                   Color="Color.Primary" />
        <MudSwitch @bind-Value="@(AppSettings.IsAutoCheckUpdate)"
                   @bind-Value:after="SaveSettings"
                   Label="@(Lang["AutoCheckUpdate"])"
                   Color="Color.Primary" />

        <MudSelect Class="mt-3"
                   T="string"
                   Label="语言 Lang"
                   Value="@(AppSettings.Lang.ToString())"
                   ValueChanged="LangValueChanged">
            <MudSelectItem Value="@("zh")">中文</MudSelectItem>
            <MudSelectItem Value="@("en")">en</MudSelectItem>
        </MudSelect>

        <MudButton Class="mt-3"
                   Variant="Variant.Text"
                   Color="Color.Primary"
                   Size="Size.Small"
                   OnClick="ResetSettingsAsync">@(Lang["ResetSettings"])</MudButton>

        <div class="mt-10 d-flex align-center">
            <MudChip T="string"
                     Label="true"
                     Disabled="true"
                     Size="Size.Small">
                @(Lang["LogFiles"])
            </MudChip>

            @if (!_logLoadingOk)
            {
                <MudProgressCircular Color="Color.Primary"
                                     Class="ml-2"
                                     Size="Size.Small"
                                     Indeterminate="true" />
            }
            else
            {
                <MudChip T="string"
                         Label="true"
                         Disabled="true"
                         Size="Size.Small">
                    @($"{_logFilesSize / 1024 / 1024:N2} MB")
                </MudChip>

                <MudButton Variant="Variant.Text"
                           Color="Color.Primary"
                           Size="Size.Small"
                           OnClick="OpenLogPath">@(Lang["OpenLogs"])</MudButton>
                <MudButton Variant="Variant.Text"
                           Color="Color.Primary"
                           Size="Size.Small"
                           OnClick="ClearLogAsync">@(Lang["RemoveLogs"])</MudButton>
            }
        </div>
        <div class="mt-4 d-flex align-center">
            <MudChip T="string"
                     Label="true"
                     Disabled="true"
                     Size="Size.Small">
                @(_version)
            </MudChip>
            <MudButton Variant="Variant.Text"
                       Color="Color.Primary"
                       Size="Size.Small"
                       OnClick="CheckUpdateAsync">@(Lang["CheckUpdate"])</MudButton>
            <MudButton Href="@(Resource.GitHubUrl)"
                       Target="_blank"
                       Variant="Variant.Text"
                       Size="Size.Small"
                       EndIcon="@Icons.Custom.Brands.GitHub"
                       Color="Color.Primary">
                GitHub
            </MudButton>
        </div>
    </MudDrawerContainer>
</MudDrawer>